<?php
// status check: Session quantum = one to one > new array | one to array | array to array
// correct following code
$sessdircount = count($_SESSION['dirs']);
$sessfilecount = count($_SESSION['files']);
$postdircount = count($_POST['dirs']);
$postfilecount = count($_POST['files']);

if ($sessdircount == 0){
    $_SESSION['dirs'] = $_POST['dirs'];
}elseif ($sessdircount > 0){
    if($postdircount == 1 && $sessdircount == 1){
        $_SESSION['dirs'] = array($_SESSION['dirs'][0],$_POST['dirs'][0]);
        $sesstemp = new remove_dups($_SESSION['dirs']);
        $_SESSION['dirs'] = $sesstemp->unique;
    } elseif ($postdircount == 1 && $sessdircount > 1){
        $_SESSION['dirs'][] = $_POST['dirs'][0];
        $sesstemp = new remove_dups($_SESSION['dirs']);
        $_SESSION['dirs'] = $sesstemp->unique;
    }elseif ($postdircount > 1 && $sessdircount == 1){
        $sesstemp[0] = array($_SESSION['dirs'][0]);
        $_SESSION['dirs'] = array_merge($_SESSION['dirs'],$_POST['dirs']);
        $sesstemp = new remove_dups($_SESSION['dirs']);
        $_SESSION['dirs'] = $sesstemp->unique;
    } elseif ($postdircount > 1 && $sessdircount > 1){
        $_SESSION['dirs'] = array_merge($_SESSION['dirs'],$_POST['dirs']);
        $sesstemp = new remove_dups($_SESSION['dirs']);
        $_SESSION['dirs'] = $sesstemp->unique;
    }
}
if ($sessfilecount == 0){
    $_SESSION['files'] = $_POST['files'];
}elseif ($sessfilecount > 0){
    if($postfilecount == 1 && $sessfilecount == 1){
        $_SESSION['files'] = array($_SESSION['files'][0],$_POST['files'][0]);
        $sesstemp = new remove_dups($_SESSION['files']);
        $_SESSION['files'] = $sesstemp->unique;
    } elseif ($postfilecount == 1 && $sessfilecount > 1){
        $_SESSION['files'][] = $_POST['files'][0];
        $sesstemp = new remove_dups($_SESSION['files']);
        $_SESSION['files'] = $sesstemp->unique;
    }elseif ($postfilecount > 1 && $sessfilecount == 1){
        $sesstemp[0] = array($_SESSION['files'][0]);
        $_SESSION['files'] = array_merge($_SESSION['files'],$_POST['files']);
        $sesstemp = new remove_dups($_SESSION['files']);
        $_SESSION['files'] = $sesstemp->unique;
    } elseif ($postfilecount > 1 && $sessfilecount > 1){
        $_SESSION['files'] = array_merge($_SESSION['files'],$_POST['files']);
        $sesstemp = new remove_dups($_SESSION['files']);
        $_SESSION['files'] = $sesstemp->unique;
    }
}
?>